<?php
/**
 * Created by PhpStorm.
 * User: 96572
 * Date: 2017/5/1
 * Time: 15:21
 */
use yii\helpers\Html;


/* @var $this yii\web\View */
/* @var $model app\modules\admin\models\User */


function getTr($menu,$level,$view){
    $menu['menu_label'] = str_pad('',$level,'-') . $menu['menu_label'];
    $menuTr = $view->render('tr',[
            'level'=>$level,
            'menu'=>$menu
    ]);
    if (isset($menu['children']) && is_array($menu['children']) && count($menu['children']))
    {
        foreach ($menu['children'] as $child) {
            $menuTr .= getTr($child,$level + 1,$view);
        }
    }
    return $menuTr;
}
?>
<div class="menu-list">

    <h1><?= Html::encode($this->title) ?></h1>
    <table class="table table-bordered table-hover">
        <thead>
        <tr>
            <th>菜单名称</th>
            <th>是否最下级菜单</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach ($menus as $item) {?>
            <?=getTr($item,0,$this)?>
        <?php } ?>

        </tbody>
    </table>

</div>